<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <meta charset="UTF-8">
    <title>联合登录</title>
    <link rel="stylesheet" href="./css/style.min.css">
</head>
<script type="text/javascript">
    window.onload=function () {
            document.addEventListener('touchstart',function (event) {
                if(event.touches.length>1){
                    event.preventDefault();
                }
            })
            var lastTouchEnd=0;
            document.addEventListener('touchend',function (event) {
                var now=(new Date()).getTime();
                if(now-lastTouchEnd<=300){
                    event.preventDefault();
                }
                lastTouchEnd=now;
            },false)
        }
</script>

<body>
    <div id="loginchn-pg">
        <header class="cl" v-show="header.show">
            <div class="nav-bar cl">
                <span class="goback arrow_l" @click="goback"></span>
                <span class="page-name">联合登录</span>
            </div>
        </header>
        <div class="loginchn-wrap">
            <p class="headimg-wrap"><img :src="head_img" ></p>
            <p class="greeting"><label class="hint">新爱的用户：</label><span class="nickname" v-cloak>{{nickname}}</span></p>
            <p>为了给您更好的服务，请关联一个本店账号</p> 
            <div class="btn-wrap">
               <p class="hint">还没账号</p>
                <a href="#" class="btn btn-reg" @click.prevent="reglink">立即注册</a> 
            </div>
            <div class="btn-wrap">
                <p class="hint">已有账号</p>
            <a href="#" class="btn btn-bind" @click.prevent="bindlink">立即绑定</a> 
            </div>
        </div>
        
        <toast ref="toast"></toast>
    </div>
    <script src="./js/lib/vue.js"></script>
    <script src="http://static.jdhui.com/lib/vue-resource/1.2/vue-resource.js"></script>
    <script src="./js/min/config.min.js"></script>
    <script type="text/javascript" src="./js/min/common.min.js"></script>
    <script src="./js/min/component.min.js"></script>
    <script>
    var toast = new component.popup.toast();
    var store_id=APP.getQueryString("storeid");
    var headimg=APP.getQueryString("head_img");
    var nickname=APP.getQueryString("name");
    if (nickname) {
        nickname=decodeURIComponent(nickname);
    }
    var regid=APP.getQueryString("register_id");
    console.log(headimg)
    var forgot = new Vue({
        el: "#loginchn-pg",
        data: {
			header:{
				show: !APP.iswechat()
			},
            head_img:headimg,
            nickname:nickname

        },
        methods: {
            goback: function() {
                window.history.go(-1);
            },
            reglink:function () {
                window.location.href="bind.html?bind=2&register_id="+regid+"&storeid="+store_id+'&src=wx';
            },
            bindlink:function () {
                window.location.href="bind.html?bind=1&register_id="+regid+"&storeid="+store_id+'&src=wx';
            },
            btnsubmit: function () {
                var _cellnum=this.cellnum,
                regexphone = /^1\d{10}$/,
                smscode=this.smscode,
                passwda=this.newpassa,
                passwdb=this.newpassb;
                
                Vue.http.options.xhr = {
                withCredentials: true
            }
            Vue.http.options.credentials = true;
                Vue.http.post(APIPHP+'index.php?r=home/index/find-pwd&storeid='+store_id, {
                        mobile: _cellnum,
                        sms_code: smscode,
                        password: passwda,
                        repassword: passwdb
                    },{emulateJSON:true}).then(function (_res) {
                        if (_res.body.flag==1) {
                           forgot.$refs.toast.show("密码已重置，请重新登录"); 
                           setTimeout(window.location.href="login.html?storeid="+store_id,3000)
                           
                        }else {
                            forgot.$refs.toast.show(_res.body.msg); 
                        }
                        
                    })
            }
        }
    })
    </script>
</body>

</html>
